<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>计数器</title>
		<script src="vue.js" type="text/javascript"></script>
	</head>
	<body>
		<div id="app">
			
				<button @click="sub">-</button>
			
					<span>{{ num }}</span>
			
				<button @click="add">+</button>
			
		</div>
		<script>
			var app=new Vue({
				el:"#app",
				data:{
					num:0
				},
				methods: {
					add:function(){
						if (this.num<10) {
							this.num++;
						} else{
							alert("别点啦，最大了！")
						}
					},
					sub:function(){
						if (this.num>0) {
							this.num--;
						} else{
							alert("别点啦，最小了！")
						}
					}
				},
			})
		</script>
	</body>
</html>
